include ../config.mk

DOTC = $(wildcard *.c)
OFILES = $(DOTC:.c=.o)

    ALL = stub $(OFILES)
 CFILES = alig.c compile.c dlopen_ffi.c hash.c llmath.c
 OFILES = alig.o compile.o dlopen_ffi.o hash.o llmath.o
   ARCH = tinf/libtinf.a
  PIGGY = *.o stub.c

    OPT = -DUSE_DLOPEN -DNDEBUG -DWANT_UNISTD_H -Os -fomit-frame-pointer \
          -DSELF=\"/proc/self/exe\"
 CFLAGS += $(OPT) -DMPROTECT
# If you have NX protection, try: -DMPROTECT
#     If you want to trace input: -DECHOVAL=1

MYFLAGS = $(CFLAGS) $(LDFLAGS) $(NEEDLDL)

all: $(ALL)

stub.c: 4p.ci
	perl ciic.pl <4p.ci >stub.c

stub: stub.c $(OFILES) $(ARCH)
	$(CC) $(MYFLAGS) stub.c $(OFILES) $(ARCH) -o stub
	-$(STRIP) -R .comment stub
	$(STRIP) stub
#	-upx-ucl-beta stub
#	-gzexe stub

tinf/libtinf.a:
	cd tinf && $(MAKE)

clean:
	-rm *~

distclean: clean
	-rm $(ALL) $(PIGGY)
	cd tinf && $(MAKE) distclean
